﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Twitterizer;

namespace Twillo.Core.Controls
{
    public class TwitterTrendList : TableLayoutPanel
    {

        public TwitterTrendCollection Trends { get { return _trends; } set { _trends = value; RefreshList(); } }

        private TwitterTrendCollection _trends = null;

        protected override void InitLayout()
        {
            base.InitLayout();
        }

        private void RefreshList()
        {
            this.Controls.Clear();
            if (_trends == null) { return; }
            this.RowStyles.Clear();
            this.RowCount = 0;
            this.ColumnCount = 1;
            int rowindex = 1;

            foreach (TwitterTrend trend in _trends)
            {
                LinkLabel lbl = new LinkLabel();
                lbl.Text = trend.SearchQuery;
                lbl.Tag = trend.Address;
                this.Controls.Add(lbl, 1, rowindex);
                this.RowStyles.Add(new RowStyle() { SizeType = System.Windows.Forms.SizeType.AutoSize });
                rowindex += 1;
            }
        }
    }
}
